/**
 * Created by shaotingzhou on 2016/12/13.
 */
/**
 *  有效期modal
 */
import React, { Component } from 'react';
import {
    AppRegistry,
    StyleSheet,
    Text,
    View,
    ListView,
    Image,
    TouchableOpacity,
    Platform,
    TextInput,
    Dimensions,
    AsyncStorage,
    Picker
} from 'react-native';

var Width = Dimensions.get('window').width; //屏宽
var Height = Dimensions.get('window').height; //屏高
var itemAry = ["一个月","二个月","三个月","四个月","五个月","六个月"];

class ValidSpicker extends  React.Component {
    constructor(props) {
        super(props);
        // 初始状态
        this.state = {
            isOn:false,
            pickerLabel:'一个月',//请选择供应信息显示时间
            slideNum:0
        };
    }
    render () {
        return (
            <View style={styles.container}>
                {/*阴影*/}
                <TouchableOpacity onPress={()=>this.passMethod()}>
                    <View style={styles.shadowView}>
                    </View>
                </TouchableOpacity>
                {/*modal*/}
                <View style={styles.modalStyle}>

                    <View style={styles.modalTop}>
                        <Text>选择基酒有效期</Text>
                    </View>

                    <View style={{width:50,flexDirection:'row',marginLeft:Width-50}}>
                        <Text onPress={()=>this.passMethod()} style={{textAlign:'right',marginTop:-15}}>完成</Text>
                    </View>

                    <View style={{height:1,backgroundColor:'#E0EEEE',marginTop:10}}></View>
                    <Picker style={{width:Width,height:200}}
                            selectedValue = {this.state.pickerLabel}
                            onValueChange = {(e) => this.setState({pickerLabel:e})}>
                        {
                            itemAry.map((item) => {
                                return(
                                    <Picker.Item key={item} label={item} value={item} />
                                )
                            })
                        }
                    </Picker>

                </View>
            </View>
        )
    }
    /*
     *   点击传递方法
     *   @param 无
     *   @returns 无
     * */
    passMethod = ()=>{
        var selectValue = this.state.pickerLabel
        this.props.modalHidden(selectValue)
    }
}

var styles = StyleSheet.create({
    container:{
        flex:1,
    },
    //shadow
    shadowView:{
        backgroundColor:'black',
        opacity:0.5,
        height: Height*0.7,
        width: Width,
    },
    //modal
    modalStyle:{
        backgroundColor:'white',
        width: Width,
        height: Height-Height*0.7,
    },
    // modalTop
    modalTop: {
        flexDirection: 'row',
        justifyContent: 'center',
        alignItems: 'center',
        marginTop: 10
    }
});

module.exports = ValidSpicker;
